﻿Option Strict On

Namespace Negocios

    Public Class Item

#Region "Variáveis"


#End Region

#Region "Propriedades"


#End Region

#Region "Construtores"


#End Region

#Region "Funções privadas"

        Private Function ConverteDataTableEmLista(ByVal dtRetorno As DataTable) As List(Of Objetos.Item)

            Try

                Dim lisItem As New List(Of Objetos.Item)
                Dim objItem As Objetos.Item

                For Each drLinha As DataRow In dtRetorno.Rows

                    objItem = New Objetos.Item

                    With objItem

                        .Codigo = Convert.ToInt32(drLinha("Codigo"))
                        .Nome = Convert.ToString(drLinha("Nome"))
                        .Custo = Convert.ToInt32(drLinha("Custo"))
                        If Not IsDBNull(drLinha("CodigoRecomendado")) Then .CodigoRecomendado = Convert.ToInt32(drLinha("CodigoRecomendado"))
                        .Health = Convert.ToDecimal(drLinha("Health"))
                        .Health_regen = Convert.ToDecimal(drLinha("Health_regen"))
                        .Resource_type = CType(drLinha("Resource_type"), Geral.Geral.Tipo_Recurso)
                        .Resource = Convert.ToDecimal(drLinha("Resource"))
                        .Resource_regen = Convert.ToDecimal(drLinha("Resource_regen"))
                        .Attack_damage = Convert.ToDecimal(drLinha("Attack_damage"))
                        .Attack_damage_level = Convert.ToDecimal(drLinha("Attack_damage_level"))
                        .Ability_power = Convert.ToDecimal(drLinha("Ability_power"))
                        .Ability_power_level = Convert.ToDecimal(drLinha("Ability_power_level"))
                        .Attack_speed = Convert.ToDecimal(drLinha("Attack_speed"))
                        .Armor = Convert.ToDecimal(drLinha("Armor"))
                        .Magic_resist = Convert.ToDecimal(drLinha("Magic_resist"))
                        .Movement_speed = Convert.ToDecimal(drLinha("Movement_speed"))
                        .Movement_speed_perc = Convert.ToDecimal(drLinha("Movement_speed_perc"))
                        .Life_steal = Convert.ToDecimal(drLinha("Life_steal"))
                        .Critical = Convert.ToDecimal(drLinha("Critical"))
                        .Spell_vamp = Convert.ToDecimal(drLinha("Spell_vamp"))
                        .Cooldown_reduction = Convert.ToDecimal(drLinha("Cooldown_reduction"))
                        .Armor_pen = Convert.ToDecimal(drLinha("Armor_pen"))
                        .Armor_pen_perc = Convert.ToDecimal(drLinha("Armor_pen_perc"))
                        .Magic_pen = Convert.ToDecimal(drLinha("Magic_pen"))
                        .Magic_pen_perc = Convert.ToDecimal(drLinha("Magic_pen_perc"))
                        .Tenacity = Convert.ToDecimal(drLinha("Tenacity"))
                        .Gold_per_sec = Convert.ToDecimal(drLinha("Gold_per_sec"))
                        .Observacoes = Convert.ToString(drLinha("Observacoes"))

                    End With

                    lisItem.Add(objItem)

                Next

                Return lisItem

            Catch ex As Exception
                Throw
            End Try

        End Function

#End Region

#Region "Funções Friend"


#End Region

#Region "Funções públicas"

        Public Function RetornarListaItens() As List(Of Objetos.Item)

            Try

                Dim objConexao As New LoLLibrary.Dados.Conexao
                Return ConverteDataTableEmLista(objConexao.RetornarDataTable("Select * from Itens Order by Nome asc"))

            Catch ex As Exception
                Throw
            End Try


        End Function

        Public Shared Function TrataNomeChampion(ByVal strNomeChampion As String) As String

            Return strNomeChampion.Replace(" ", String.Empty).Replace("'", String.Empty).Replace(".", String.Empty)

        End Function

#End Region


    End Class

End Namespace
